<?php 
namespace CLUB\Controller;
use Think\Controller;
/**
* 大师管理业务逻辑
*/
class MmController extends PubController
{
	public function mmlist(){
	   $m = M('Maestro');
	   $count = $m -> count();
	   $pagesize = 15;
	   $Page = new \Think\Page($count,$pagesize);// 实例化分页类 传入总记录数和每页显示的记录数
	   $list = $m->limit($Page->firstRow.','.$Page->listRows)->select();
	   $Page->setConfig('prev', '上一页');
       $Page->setConfig('next', '下一页');
	   $show = $Page -> show();
	   $this -> assign('mmlist',$list);
	   $this -> assign("page",$show);
	   $this -> display();
	}
	/**
	 * 初始化大师账号
	 * @return [type] [description]
	 */
	public function addmm(){
		$this -> display();
	}
	public function doingadd(){
		$m = M('Maestro');
		$m->mname = I('post.mname');
		$m->mpwd = $this ->HdEncrypt("123"); 
		$m->clubid = $_SESSION['clubid'];
		$m->mintro = I('post.mintro');
		$mpic = $this ->uploadfile($_FILES['mpic'],'./Public/upload/');
		$m->mpic = $mpic;
		if (false!=$m->add()) {
		    $this -> Thumbnail('./Public/upload/',$mpic);
		    $this -> redirect("Mm/mmlist",'',2,"初始化大师账号成功，页面跳转中...");
		}else{
			$this -> error("哎呀！出错了...");
		}
	}
}